package com.ruoyi.labdata.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.labdata.domain.LabPlatformSubordinate;
import com.ruoyi.labdata.service.ILabPlatformSubordinateService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * subordinateController
 * 
 * @author winner pan
 * @date 2022-04-29
 */
@RestController
@RequestMapping("/labdata/subordinate")
public class LabPlatformSubordinateController extends BaseController
{
    @Autowired
    private ILabPlatformSubordinateService labPlatformSubordinateService;

    /**
     * 查询subordinate列表
     */
    @PreAuthorize("@ss.hasPermi('labdata:subordinate:list')")
    @GetMapping("/list")
    public TableDataInfo list(LabPlatformSubordinate labPlatformSubordinate)
    {
        startPage();
        List<LabPlatformSubordinate> list = labPlatformSubordinateService.selectLabPlatformSubordinateList(labPlatformSubordinate);
        return getDataTable(list);
    }

    /**
     * 导出subordinate列表
     */
    @PreAuthorize("@ss.hasPermi('labdata:subordinate:export')")
    @Log(title = "subordinate", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(LabPlatformSubordinate labPlatformSubordinate)
    {
        List<LabPlatformSubordinate> list = labPlatformSubordinateService.selectLabPlatformSubordinateList(labPlatformSubordinate);
        ExcelUtil<LabPlatformSubordinate> util = new ExcelUtil<LabPlatformSubordinate>(LabPlatformSubordinate.class);
        return util.exportExcel(list, "subordinate");
    }

    /**
     * 获取subordinate详细信息
     */
    @PreAuthorize("@ss.hasPermi('labdata:subordinate:query')")
    @GetMapping(value = "/{subordinateId}")
    public AjaxResult getInfo(@PathVariable("subordinateId") Long subordinateId)
    {
        return AjaxResult.success(labPlatformSubordinateService.selectLabPlatformSubordinateById(subordinateId));
    }

    /**
     * 新增subordinate
     */
    @PreAuthorize("@ss.hasPermi('labdata:subordinate:add')")
    @Log(title = "subordinate", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody LabPlatformSubordinate labPlatformSubordinate)
    {
        return toAjax(labPlatformSubordinateService.insertLabPlatformSubordinate(labPlatformSubordinate));
    }

    /**
     * 修改subordinate
     */
    @PreAuthorize("@ss.hasPermi('labdata:subordinate:edit')")
    @Log(title = "subordinate", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody LabPlatformSubordinate labPlatformSubordinate)
    {
        return toAjax(labPlatformSubordinateService.updateLabPlatformSubordinate(labPlatformSubordinate));
    }

    /**
     * 删除subordinate
     */
    @PreAuthorize("@ss.hasPermi('labdata:subordinate:remove')")
    @Log(title = "subordinate", businessType = BusinessType.DELETE)
	@DeleteMapping("/{subordinateIds}")
    public AjaxResult remove(@PathVariable Long[] subordinateIds)
    {
        return toAjax(labPlatformSubordinateService.deleteLabPlatformSubordinateByIds(subordinateIds));
    }
}
